<?php
/**
 * Created by PhpStorm.
 * User: zhang
 * Date: 2018/1/29
 * Time: 16:57
 */
/* 使用当前的 detect_order 来检测字符编码 */

echo mb_internal_encoding().PHP_EOL;

$str = '您好 China';
//windows平台的终端一般都是GBK编码
echo mb_convert_encoding($str,"GBK","UTF-8").PHP_EOL;
//Windows (gbk) ==> 您好 China
//Linux   (utf-8) ==>  źº`China

echo mb_detect_encoding($str).PHP_EOL;
echo $str.PHP_EOL;
/* "auto" 将根据 mbstring.language 来扩展 */
echo mb_detect_encoding($str, "auto").PHP_EOL;
echo $str.PHP_EOL;

/* 通过逗号分隔的列表来指定编码列表 encoding_list */
echo mb_detect_encoding($str, "JIS, eucjp-win, sjis-win").PHP_EOL;
echo $str.PHP_EOL;

/* 使用数组来指定编码列表 encoding_list  */
$ary[] = "ASCII";
$ary[] = "JIS";
$ary[] = "EUC-JP";
echo mb_detect_encoding($str, $ary).PHP_EOL;
echo $str.PHP_EOL;
